#ifndef __IRQDESC_H__
#define __IRQDESC_H__

#include "linux/wait.h"
#include "linux/bitmap.h"
#include "linux/interrupt.h"
#include "linux/irq.h"
#include "linux/irqhandler.h"

enum irqreturn
{
    IRQ_NONE = (0 << 0),
    IRQ_HANDLED = (1 << 0),
    IRQ_WAKE_THREAD = (1 << 1),
};

struct irq_desc
{
    char		*name;
    unsigned int irq_num;
    
    struct irq_common_data	irq_common_data;
    struct irq_data irq_data;

    irq_flow_handler_t	handle_irq;
    struct irqaction	*action;	/* IRQ action list */
    unsigned int		depth;		/* nested irq disables */
	unsigned int		wake_depth;	/* nested wake enables */
	unsigned int		irq_count;	/* For detecting broken IRQs */
    unsigned int		irqs_unhandled;
    unsigned int        istate;		/* IRQ state */
    atomic_t		    threads_active;
    wait_queue_t        wait_for_threads;
    unsigned int		status_use_accessors;
    
    unsigned int flag;     /* 低电平 高电平 下降沿 上升沿 等*/
    unsigned int count;     /* 此中断发生的次数  */
    
    void (*set_flag)(unsigned int irq_num, unsigned int flags);
    void (*mask)(unsigned int irq_num);
    void (*unmask)(unsigned int irq_num);

    unsigned int cpu;
};

struct irq_desc *irq_to_desc(unsigned int irq);
void irq_free_descs(unsigned int from, unsigned int cnt);
void irq_free_desc(unsigned int irq);
int handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, struct pt_regs *regs);
struct irq_desc *irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int check);
void irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags);
struct irq_desc* irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check);
void irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags);
int generic_handle_irq(unsigned int irq);

#endif
